import {AfterViewInit, Component, OnInit} from "@angular/core";
import {BaseComponent} from "../../base.component";
import {ArticleService} from "../article.service";
import {ArrayModel} from "../../model/ArrayModel";
import {ms_article} from "../../model/ms_article";
import {ArticleTypeEnum} from "../../model/ArticleTypeEnum";
import {ActivatedRoute, Params} from "@angular/router";
import 'rxjs/add/operator/switchMap';
import { Observable } from 'rxjs/Observable';


declare const UM:any;

@Component({
    selector: 'my-rightContent',
    templateUrl:"./article.list.component.html",
    styleUrls:["./article.list.component.css"]

})
export class ArticlesList extends BaseComponent implements OnInit{

    _arrayList=new ArrayModel(ms_article);

    _type:ArticleTypeEnum=ArticleTypeEnum.article;

    constructor(
        private service:ArticleService,
        private route:ActivatedRoute
    ){
        super();
    }


    ngOnInit(): void {

            let arrayList=this.route.params.switchMap((parms:Params)=>{
                return this.service.getArticlesList(this._type);
            });





            this.service.getArticlesList(this._type)
                .then(response=>{
                    if(response.result)
                    {

                    }else
                    {
                        this.dialog.dangerShow(response.message);
                    }

                })
                .catch(ex=>this.setMessage(ex))




    }
}
